package com.ttctracker.search;

import java.util.ArrayList;
import com.ttctracker.classes.Direction;


import android.R;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class DirectionArrayAdapter extends ArrayAdapter<Direction>{

	private ArrayList<Direction> directions;
	
	public DirectionArrayAdapter(Context context, int textViewResourceId,
			ArrayList<Direction> objects) {
		super(context, textViewResourceId, objects);
		directions=objects;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		
		View v = convertView;
		if (v == null) {
			LayoutInflater vi = (LayoutInflater) getContext().getSystemService(
					Context.LAYOUT_INFLATER_SERVICE);
			v = vi.inflate(android.R.layout.simple_spinner_item, null);
		}
		
		Direction direction=directions.get(position);
		if (direction!=null) {
			TextView directionText=(TextView)v.findViewById(R.id.text1);
			directionText.setText(direction.get_title());
		}
		return v;
	}
	

}
